const ApiDef = require('./impl')
const kong_cfg = configure.get('kong')

class consumerService {
    constructor () {
        this.apiBaseUrl = kong_cfg.kong_admin
    }

    get (custom_id) {
        return ApiDef.get(`${this.apiBaseUrl}consumers/${custom_id}`)
    }

    delete (custom_id) {
        return ApiDef.delete(`${this.apiBaseUrl}consumers/${custom_id}`)
    }

    add (data) {
        return ApiDef.post(`${this.apiBaseUrl}consumers`, data)
    }

    // 更新
    patch (custom_id, data) {
        return ApiDef.patch(`${this.apiBaseUrl}consumers/${custom_id}`, data)
    }

    // 更新或者创建
    put (custom_id, data) {
        return ApiDef.put(`${this.apiBaseUrl}consumers/${custom_id}`, data)
    }
}

module.exports = new consumerService()

